import cv2 as cv


img_color = cv.imread("image/03.jpg",cv.IMREAD_COLOR)

cv.imshow("img_color", img_color)

# 图色转换，转灰色
img_grey = cv.cvtColor(img_color, cv.COLOR_BGR2GRAY)
cv.imshow("img_grey", img_grey)

# 阈值处理
t, t_img = cv.threshold(img_grey, 0, 255, cv.THRESH_BINARY + cv.THRESH_OTSU)
# 判断的阈值
print(t)
cv.imshow("t_img", t_img)

# 自适应阈值处理
rea_img = cv.adaptiveThreshold(img_grey, 255, cv.ADAPTIVE_THRESH_MEAN_C,
cv.THRESH_BINARY, 175, 1)
cv.imshow("rea_img", rea_img)
# 按下任意键停止
cv.waitKey()
cv.destroyAllWindows()